/*
 * @Author: funlee
 * @Email: i@funlee.cn
 * @Date: 2018-01-11 22:33:08
 * @Last Modified time: 2018-01-11 22:33:08
 * @Description: 渐变调色板 
 */
window.onload = function () {
  var canvas = document.querySelector('.canvas')
  var cxt = canvas.getContext('2d')

  var r = 255, g = 0, b = 0
  for (i = 0; i < 150; i++) {
    if (i < 25) {
      g += 10
    } else if (i > 25 && i < 50) {
      r -= 10
    } else if (i > 50 && i < 75) {
      g -= 10
      b += 10
    } else if (i >= 75 && i < 100) {
      r += 10
    } else {
      b -= 10
    }
    cxt.fillStyle = 'rgb(' + r + ',' + g + ',' + b + ')'
    cxt.fillRect(3 * i, 0, 3, canvas.height)
  }
}
